在MSWord表格单元格中使用公式

时间:2017-01-25 21:03:30

标签: vba ms-word automation

我在这里结束了我的智慧。我一直在尝试在Microsoft Word 2013 Table上为几个单元格自动计算。我首先尝试创建VBA脚本并且它有效,但我需要在保护模式下使用模板,这使得VBA脚本无法使用!所以我尝试在单元格中添加一个公式,但我意识到如果单元格没有任何值,则输出0而不是空白单元格。如何输出空白单元而不是0?

这是我的公式代码: = PRODUCT(R8C9,R8C1,R8C6)

= SUM(R8C10,R9C10,R10C10,R11C10,R12C10,R13C10,R14C10,R15C10,R16C10,R17C10,R18C10,R19C10,R20C10,R21C10,R22C10,R23C10,R24C10,R25C10,R26C10,R27C10,R28C10,R29C10, R30C10,R32C3)

不可用的VBA代码

public class PaymentsFragment extends Fragment implements View.OnClickListener, GoogleApiClient.OnConnectionFailedListener {

private GoogleApiClient mGoogleApiClient;
private MaskedWallet mMaskedWallet;

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
                .addOnConnectionFailedListener(this)
                .addApi(Wallet.API, new Wallet.WalletOptions.Builder()
                        .setEnvironment(BuildConfig.DEBUG ? WalletConstants.ENVIRONMENT_TEST : WalletConstants.ENVIRONMENT_PRODUCTION)
                        .setTheme(WalletConstants.THEME_LIGHT)
                        .build())
                .enableAutoManage(getActivity(), this)
                .build();

Wallet.Payments.isReadyToPay(mGoogleApiClient).setResultCallback(
                new ResultCallback<BooleanResult>() {
                    @Override
                    public void onResult(@NonNull BooleanResult booleanResult) {
                        if (booleanResult.getStatus().isSuccess()) {
                            if (booleanResult.getValue()) {
                                showAndroidPay();
                            }
                        }
                    }
                });
  }

private void showAndroidPay() {
WalletFragmentStyle walletFragmentStyle = new WalletFragmentStyle()
.setBuyButtonText(WalletFragmentStyle.BuyButtonText.LOGO_ONLY)
.setBuyButtonAppearance(WalletFragmentStyle.BuyButtonAppearance.ANDROID_PAY_LIGHT)
.setBuyButtonHeight(WalletFragmentStyle.Dimension.UNIT_DIP, 46);

  WalletFragmentOptions walletFragmentOptions = WalletFragmentOptions.newBuilder()
                .setEnvironment(BuildConfig.DEBUG ? WalletConstants.ENVIRONMENT_TEST : WalletConstants.ENVIRONMENT_PRODUCTION)
                .setFragmentStyle(walletFragmentStyle)
                .setTheme(WalletConstants.THEME_LIGHT)
                .setMode(WalletFragmentMode.BUY_BUTTON)
                .build();

        PaymentMethodTokenizationParameters params = null;
        if (requestMethod.getGateway().getType() == PaymentGateway.PaymentGatewayType.STRIPE) {
            params = PaymentMethodTokenizationParameters.newBuilder()
                    .setPaymentMethodTokenizationType(PaymentMethodTokenizationType.PAYMENT_GATEWAY)
                    .addParameter(GOOGLE_WALLET_GATEWAY, PaymentGateway.PaymentGatewayType.STRIPE.toString().toLowerCase())
                    .addParameter(GOOGLE_WALLET_STRIPE_KEY, ((StripePaymentGateway) requestMethod.getGateway()).getPublishableKey())
                    .addParameter(GOOGLE_WALLET_STRIPE_VERSION, com.stripe.Stripe.VERSION)
                    .build();
        } else {
            //later
        }

        MaskedWalletRequest maskedWalletRequest = MaskedWalletRequest.newBuilder()
                .setMerchantName("")
                .setPaymentMethodTokenizationParameters(params)
                .setPhoneNumberRequired(false)
                .setShippingAddressRequired(false)
                .setEstimatedTotalPrice(100.0)
                .setCurrencyCode("USD")
                .build();

        WalletFragmentInitParams initParams = WalletFragmentInitParams.newBuilder()
                .setMaskedWalletRequest(maskedWalletRequest)
                .setMaskedWalletRequestCode(LOADER_MASKED_WALLET_REQUEST_CODE)
                .build();

        SupportWalletFragment walletFragment = SupportWalletFragment.newInstance(walletFragmentOptions);
        walletFragment.initialize(initParams);

 if (walletFragment != null) {
            getFragmentManager().beginTransaction()
                    .replace(R.id.androidpay_fragment_holder, walletFragment)
                    .commit();

        }
  }
}

enter image description here

0 个答案:

没有答案